package org.hhchat.leetcode.tree;

import org.hhchat.leetcode.dataStruct.TreeNode;

/**
 * Created this one by HMH on 2017/10/2.
 */
public class code404_easy {

    static class Solution {
        public int sumOfLeftLeaves(TreeNode root) {
            if (root == null) {
                return 0;
            }
            visit(root.left,true);
            visit(root.right, false);
            return sum;
        }

        int sum = 0;

        public void visit(TreeNode root, boolean fromLeft) {
            if (root == null) {
                return ;
            }
            if (root.left == null && root.right == null && fromLeft) {
                sum += root.val;
            }
            visit(root.left, true);
            visit(root.right, false);
        }
    }

    public static void main(String[] args){

    }

}
